package com.aat.dxfy.dxyStart;

import java.io.*;

import org.apache.poi.xssf.usermodel.*;

public class ReadXlsmTest {

	public static void main(String[] args) throws IOException {
		InputStream is = new FileInputStream("F:/桌面/e众筹/tab.xlsm");
		@SuppressWarnings("resource")
		XSSFWorkbook xssfWorkbook = new XSSFWorkbook(is);
		for (int numSheet = 1; numSheet < xssfWorkbook.getNumberOfSheets(); numSheet++) {
			XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(numSheet);
			if (null != xssfSheet) {
				// 装数
				String entity = xssfSheet.getSheetName();
				String str = entity.split("_")[1];
				String beanName = str.substring(0, 1).toUpperCase()
						+ str.substring(1, str.length());
				System.out.println(entity+"  "+beanName+"\n");
				//
				for (int rowNum = 1; rowNum <= xssfSheet.getLastRowNum(); rowNum++) {
					XSSFRow xssfRow = xssfSheet.getRow(rowNum);
					String text = getXlssVal(xssfRow.getCell(1));
					String filed = getXlssVal(xssfRow.getCell(2));
					String type = getXlssVal(xssfRow.getCell(3));
					System.out.println(text+"   "+filed+"  "+type);
				}
			}

		}
		is.close();
	}

	private static String getXlssVal(XSSFCell c) {
		if (c.getCellType() == XSSFCell.CELL_TYPE_BOOLEAN) {
			return String.valueOf(c.getBooleanCellValue());
		} else if (c.getCellType() == XSSFCell.CELL_TYPE_NUMERIC) {
			return String.valueOf(c.getNumericCellValue());
		} else {
			return String.valueOf(c.getStringCellValue());
		}
	}

}
